package com.jojo.jojomall.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jojo.common.utils.PageUtils;
import com.jojo.common.utils.Query;

import com.jojo.jojomall.product.dao.AttrAttrgroupRelationDao;
import com.jojo.jojomall.product.entity.AttrAttrgroupRelationEntity;
import com.jojo.jojomall.product.service.AttrAttrgroupRelationService;


@Service("attrAttrgroupRelationService")
public class AttrAttrgroupRelationServiceImpl extends ServiceImpl<AttrAttrgroupRelationDao, AttrAttrgroupRelationEntity> implements AttrAttrgroupRelationService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<AttrAttrgroupRelationEntity> page = this.page(
                new Query<AttrAttrgroupRelationEntity>().getPage(params),
                new QueryWrapper<AttrAttrgroupRelationEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void saveattr(Long attrGroupId, Long attrId) {
        LambdaUpdateWrapper<AttrAttrgroupRelationEntity> uw = new LambdaUpdateWrapper<>();
        uw.eq(AttrAttrgroupRelationEntity::getAttrId,attrId);
        AttrAttrgroupRelationEntity attrAttrgroupRelationEntity = new AttrAttrgroupRelationEntity();
        attrAttrgroupRelationEntity.setAttrId(attrId);
        attrAttrgroupRelationEntity.setAttrGroupId(attrGroupId);
        this.update(attrAttrgroupRelationEntity,uw);
    }

}
